import { USER_UPDATE_AGE, USER_UPDATE_NAME } from '../constants/user'
// !#1 创建 reducer
export default function user(state = { name: '奇马耶夫', age: 20 }, action) {
  switch (action.type) {
    case USER_UPDATE_NAME:
      return {
        ...state,
        name: action.payload,
      }
    case USER_UPDATE_AGE:
      return {
        ...state,
        age: action.payload,
      }
    default:
      return state
  }
}
